package com.example.yiwei.crm.view.Class.listviewClass;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.yiwei.crm.R;
import com.example.yiwei.crm.entity.AreaEntity;

import java.util.List;

/**
 * Created by DHN on 2017/4/27.
 */

public class AreAdapter extends BaseAdapter {
    private Context context;
    private List<AreaEntity> list;
    AreaEntity areaEntity;
    LayoutInflater inflater ;
    public AreAdapter(Context context, List<AreaEntity> list){
        this.context = context;
        this.list = list;
        inflater =  LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        areaEntity = list.get(position);
        if (convertView==null){
            convertView = inflater.inflate(R.layout.layout_item_are,null);
            holder = new ViewHolder();
            holder.name = (TextView) convertView.findViewById(R.id.layout_item_are_tx);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.name.setText(areaEntity.getAreaname());
        return convertView;
    }
    class ViewHolder {

        TextView name;

    }
}
